package com.tx.admin.core.service;

import java.util.List;

import org.springframework.data.domain.Page;

import com.tx.admin.core.entity.TreeEntity;
import com.tx.admin.core.po.PagePo;

public interface TreeService<E extends TreeEntity<E>> extends SuperService<E> {

	Page<E> pageBuildChildren(PagePo<E> params);
	
	E findByIdBuildParent(String id);
	
	E findByIdBuildChildren(String id);
	

	public static <E extends TreeEntity<E>> List<E> treeToLink(E parent,List<E> list) {
			if(parent == null) {
				return list ;
			}
			List<E> children = parent.getChildren();
			if(children != null) {
				list.addAll(children);
				for(E node : children) {
					treeToLink(node,list);
				}
			}
		
			return list;
	}
	
}
